#include "StdAfx.h"
#include "CodeAnalyser.h"



CodeAnalyser::CodeAnalyser(void)
{
}

CodeAnalyser::CodeAnalyser(const WCHAR* pCode ): m_pCode(pCode){

}
CodeAnalyser::~CodeAnalyser(void)
{
}

ERROR_CODE_ANALYSE CodeAnalyser::Analyse()
{
	wstringstream streamCode(m_pCode);
	wstring strCur;
	wstring strPrev;
	while (streamCode >> strCur)
	{
		if (strCur == keywordsFunc || strCur == keywordsFuncB){
			m_vecFuncNames.push_back(strPrev);
		}
		else if(strCur == keywordsByte || strCur == keywordsByteB){
			Data d;
			if(strPrev == L"") return ANA_GRAMMER_ERR;
			d.m_strDataName = strPrev;
			d.m_strDataType = L"BYTE";
			m_vecData.push_back(d);
		}
		else if(strCur == keywordsDWord || strCur == keywordsDWordB){

			Data d;
			if(strPrev == L"") return ANA_GRAMMER_ERR;
			d.m_strDataName = strPrev;
			d.m_strDataType = L"DWORD";
			m_vecData.push_back(d);
		}
		strPrev = strCur;
	}
	return ANA_SUCCEED;
}	